if (!org) var org={};
if (!org.shmk) org.shmk = {};
if (!org.shmk.fireballPrefs) org.shmk.fireballPrefs = {};

org.shmk.fireballPrefs = {
getElement: function(strID) { return document.getElementById(strID); },
prefs: null, 
startup: function(){
	var _team, _until, _interval;
	prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
	if (prefs.getPrefType("extensions.fireball.dispTeam") == prefs.PREF_STRING){
	    _team = prefs.getCharPref("extensions.fireball.dispTeam");
	}
	if (prefs.getPrefType("extensions.fireball.dispPrev") == prefs.PREF_INT){
	    _until = prefs.getIntPref("extensions.fireball.dispPrev");
	}
	if (prefs.getPrefType("extensions.fireball.interval") == prefs.PREF_INT){
	    _interval = prefs.getIntPref("extensions.fireball.interval");
	}
	if (this.getElement(_team) != null){
	    this.getElement("selectTeam").selectedItem = this.getElement(_team);
	}
	this.getElement("refreshInterval").value = _interval;
	this.getElement("prevDay").value = _until;
    },
accept: function(){
	var _until, _interval;
	_until = this.getElement("prevDay").value * 1;
	if (_until < 0 || _until > 23){
	    alert("Previous Day between 0 and 23.");
	    return false;
	}
	_interval = this.getElement("refreshInterval").value * 1;
	if (_interval < 0){
	    alert("Interval greater than 0.");
	    return false;
	}
	prefs.setCharPref("extensions.fireball.dispTeam", this.getElement("selectTeam").selectedItem.id);
	prefs.setIntPref("extensions.fireball.dispPrev", _until);	
	prefs.setIntPref("extensions.fireball.interval", _interval);
	return true;			
    }
}